﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;

using r;


namespace r.Media
{
    public class Program
    {
        public static void Main()
        {
            /*string file = "test.mp3";

            //Create a file stream from an existing file.
            FileInfo fi = new FileInfo(file);
            FileStream fs = fi.OpenRead();


            //Tag
            int nBytes = 3;
            byte[] ByteArray = new byte[nBytes];
            int nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Tag: {0}", Encoding.UTF8.GetString(ByteArray));
            //Ver. M
            nBytes = 1;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Ver. M: {0}", ByteArray[0]);
            //Ver. m
            nBytes = 1;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Ver. m: {0}", ByteArray[0]);
            //Flag
            nBytes = 1;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Flag: {0}", ByteArray[0]);
            //Size
            nBytes = 4;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Size: {0} {1} {2} {3}", ByteArray[0], ByteArray[1], ByteArray[2], ByteArray[3]);
            //Extended Size
            //nBytes = 4;
            //ByteArray = new byte[nBytes];
            //nBytesRead = fs.Read(ByteArray, 0, nBytes);
            //Console.WriteLine("Extended Size: {0} {1} {2} {3}", ByteArray[0], ByteArray[1], ByteArray[2], ByteArray[3]);
            //Extended Flags
            //nBytes = 2;
            //ByteArray = new byte[nBytes];
            //nBytesRead = fs.Read(ByteArray, 0, nBytes);
            //Console.WriteLine("Extended Flags: {0} {1}", ByteArray[0], ByteArray[1]);
            //Padding Size
            //nBytes = 4;
            //ByteArray = new byte[nBytes];
            //nBytesRead = fs.Read(ByteArray, 0, nBytes);
            //Console.WriteLine("Padding Size: {0} {1} {2} {3}", ByteArray[0], ByteArray[1], ByteArray[2], ByteArray[3]);
            //Frame ID
            nBytes = 4;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Frame ID: {0}", Encoding.UTF8.GetString(ByteArray));
            //Frame Size
            nBytes = 4;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Frame Size: {0} {1} {2} {3}", ByteArray[0], ByteArray[1], ByteArray[2], ByteArray[3]);
            //Frame Flags
            nBytes = 2;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Frame Flags: {0} {1}", ByteArray[0], ByteArray[1]);
            //Encoding
            nBytes = 1;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Encoding: {0}", ByteArray[0]);
            //Language
            nBytes = 3;
            ByteArray = new byte[nBytes];
            nBytesRead = fs.Read(ByteArray, 0, nBytes);
            Console.WriteLine("Language: {0}", Encoding.UTF8.GetString(ByteArray));


            Console.WriteLine("");
            Console.WriteLine("");

            
            Hashtable Tags = new Hashtable();
            Tags.Add("Artist", "null");
            Tags.Add("Comment", new Hashtable());
            Hashtable Original = (Hashtable)Tags["Comment"];
            Original.Add("CommLang", null);
            Console.WriteLine("Language: {0}", Original["CommLang"]);
            Original["CommLang"] = Encoding.UTF8.GetString(ByteArray);
            Console.WriteLine("Language: {0}", Original["CommLang"]);
            Console.WriteLine("Language: {0}", ((Hashtable)Tags["Comment"])["CommLang"]);
            Console.WriteLine(Tags["Artist"].GetType());
            */
            /*libr.Treetable TagTree = new libr.Treetable();
            TagTree.AddNode("T1");
            TagTree.AddNode("T1.T2");
            TagTree.AddLeaf("T1.T2.L3", "moo");

            Console.WriteLine(TagTree.GetLeaf("T1.T2.L3"));
            Console.WriteLine(TagTree.GetNode("T1.T2")["L3"]);
            */

            r.libr.Media.Tag mtag = new r.libr.Media.Tag();
            mtag.Album.Title = "moo";
            Console.WriteLine(mtag.Album.Title);
            Console.ReadKey();

        }

        /*static string GetRange(string[] buffer, int start, int end)
        {
            string result = "";
            for (int i = start; i <= end; i++)
            {
                result += buffer[i] + " ";
            }
            return result;
        }*/
    }
}